<template>
	<view class="content">
		<view class="safeZone"></view>
		<view class="font">距离(m)</view>
		<uni-number-box class="font" v-model:value="value0" v-bind:step="50" v-bind:max="10000" v-bind:min="1">
		</uni-number-box>
		<view class="font">制式</view>
		<view class="tagBox">
			<uni-tag type="success" v-for="tag in range" v-bind:text="tag.text" size="normal" :inverted="!tag.status"
				style="margin-bottom: 30rpx;" @click="handleTag(tag)"></uni-tag>
		</view>
		<view class="font">墙堵数</view>
		<uni-number-box class="font" v-model:value="value1"></uni-number-box>
		<view class="font">玻璃数</view>
		<uni-number-box class="font" v-model:value="value2"></uni-number-box>
		<view class="buttonBox">
			<button type="primary" style="position: relative;left: 15rpx;z-index: 1;" @click="handleCalc()">计算</button>
			<image src="../../static/ybbbb.jpg" class="avatar"></image>
			<button type="primary" style="position: relative;left: -15rpx;z-index: 1;" @click="handleHint()">提示</button>
		</view>
		<view class="safeZone"></view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: 'Hello',
				show: true,
				value0: 100,
				value1: 1,
				value2: 1,
				result: 0,
				kilometer: 0,
				mWatt: 0,
				fix: 0,
				day: 0,
				century:0,
				temp:240000,
				

				wall: 10,
				glass: 6,
				range: [{
					text: "4G(CDMA)",
					status: true,
					value: 2300,
					fix:240000,
					
					
				}, {
					text: "5G(NR)",
					status: false,
					value: 3500,
					fix:320000,
					
				}],
				format: 2300

			}
		},
		onLoad() {

		},
		methods: {
			handleCalc() {
				this.$data.kilometer = this.$data.value0 / 1000
				console.log("Distance:" + this.$data.kilometer + "km")
				console.log(Math.LOG10E * Math.log(this.$data.kilometer))
				console.log("Freq:" + this.$data.format + "mhz")
				console.log(Math.LOG10E * Math.log(this.$data.format))
				this.$data.result = 32.5 + 20 * (Math.LOG10E * Math.log(this.$data.kilometer)) + 20 * (Math.LOG10E * Math
					.log(this.$data.format))
				if (this.$data.result < 73) {
					this.$data.result = 73
				}
				this.$data.fix = 30 * this.$data.value1 + 20 * this.$data.value2
				console.log("fix:" + this.$data.fix)
				this.$data.result = this.$data.result + this.$data.fix
				console.log("finished 1st:" + this.$data.result)
				this.$data.result = this.$data.result / 10
				console.log("div 10:" + this.$data.result)
				this.$data.result = Math.pow(10, -this.$data.result)
				console.log("pow:" + this.$data.result)
				this.$data.result = this.$data.result * this.$data.temp //w
				console.log("320000times:" + this.$data.result)
				this.$data.mWatt = this.$data.result
				this.$data.day = (1000000 / (this.$data.mWatt)) / 24
				this.$data.day = this.$data.day.toFixed(2)
				this.$data.century = this.$data.day / 36500
				this.$data.century = this.$data.century.toFixed(0)
				console.log("世纪："+this.$data.century)
				this.$data.result = Math.LOG10E * Math.log(this.$data.result) * 10
				let _that = this
				wx.showModal({
					title: '计算结果',
					content: '当前接收功率为:' + _that.$data.result+" dbm, "+" 预计需要："+_that.$data.century+"世纪以接收一度电",
					showCancel: false,
					success: function(sm) {
						if (sm.confirm) {
							// 用户点击了确定
						} else if (sm.cancel) {
							console.log('用户点击取消')
						}
					}
				})
			},
			change(e) {
				console.log('e:', e);
			},
			handleTag(tag) {
				for (let tagx in this.$data.range) {
					this.$data.range[tagx].status = false
				}
				tag.status = !tag.status
				this.$data.format = tag.value
				this.$data.temp = tag.fix
				console.log("type amp:"+this.$data.temp)
				console.log(this.$data.format)
			},
			handleHint(){
				uni.redirectTo({
					url:"../hint/hint"
				})
			},
			handle(type) {
				this.show = !this.show
				this.modeClass = type
			},

		},
		mounted() {
			_that = this
			setTimeout(function(){_that.$data.show=false},3000)
			handle(['fade', 'slide-top'])
		}
	}
</script>

<style>
	@import url('../../components/transition-min/transition.min.css');
	.avatar {
		width: 200rpx;
		height: 200rpx;
		border-radius: 50%;
		z-index: 99;
	}

	.buttonBox {
		position: fixed;
		bottom: 40rpx;

		display: flex;
		flex-direction: row;
		align-items: center;
	}

	.font {
		font-size: 40rpx;
		margin-bottom: 30rpx;
	}

	.tagBox {
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
	}

	.safeZone {
		height: 200rpx;
	}

	.content {
		display: flex;
		font-family: 'Jetbrains Mono';
		flex-direction: column;
		align-items: center;
		justify-content: center;
		align-content: center;
		color: #c1c1c7;
	}

	.logo {
		top: 750rpx;
		height: 1500rpx;
		width: 750rpx;
		margin-top: 100rpx;
		margin-left: auto;
		margin-right: auto;
		margin-bottom: 0rpx;
	}

	.text-area {
		display: flex;
		justify-content: center;
	}

	.title {
		font-size: 36rpx;
		color: #8f8f94;
	}
</style>
